﻿@using BrnMall.Manager.Domain.Restaurant
@using BrnMall.Web.StoreAdmin.Models
@model BrnMall.Web.StoreAdmin.Models.DiningTableListModel

@section header{
    <title>餐位设置-店铺管理</title>
    <link type="text/css" rel="stylesheet" href="/admin_store/css/site.css" />
    <script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/showlist.js"></script>
    <script type="text/javascript" src="/components/jbox/jquery.jBox-2.3.min.js"></script>
}

@section body{
    <h1 class="rightH1">
        微信小程序 &gt; 店铺管理 &gt; <span class="rightH1-cur">餐位设置</span> 
        <div class="right">
            <a href="@Url.Action("EditDiningTableType")" class="menuBT"><img src="/admin_store/images/add.jpg" />添加分类</a>
            <a href="@Url.Action("EditDiningTable")" class="menuBT"><img src="/admin_store/images/add.jpg" />添加餐位</a>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </h1>

    
    <div class="dataList" style="margin-top:10px;">
        <table width="100%">
            <tr>
                <td width="30%" valign="top" style="padding-left:0px;">
                    <table width="100%">
                        <thead>
                        <tr>
                            <th width="80"></th>
                            <th align="left">分类名称</th>
                            <th align="left">管理操作</th>

                        </tr>
                        </thead>
                        <tbody>
                        @foreach (DiningTableType info in Model.TableTypes)
                        {
                            <tr>
                                <td></td>
                                <td>@info.Name</td>
                                <td>
                                    @Html.ActionLink("编辑", "EditDiningTableType", new { id = info.Id }, new { @class = "editOperate" })
                                    <span class="btn-line">|</span>
                                    @Html.ActionLink("删除", "DeleteDiningTableType", new { id = info.Id }, new { @class = "editOperate" })

                                </td>

                            </tr>
                        }
                        </tbody>
                    </table>
                </td>
                <td width="1%" ></td>
<td valign="top">
                    <table width="100%">
                        <thead>
                        <tr>
                            <th width="80"></th>
                            <th width="80">餐位编号</th>
                            <th align="left">餐位名称</th>
                            <th align="left">分类</th>
                            <th align="left">管理操作</th>

                        </tr>
                        </thead>
                        <tbody>
                        @foreach (DiningTableViewModel info in Model.DiningTables)
                        {
                            <tr>
                                <td></td>
                                <td>@info.TableNumber</td>
                                <td>@info.Name</td>
                                <td>@info.TableType.Name</td>
                                <td>
                                    @if (!string.IsNullOrEmpty(info.QrCodeUrl))
                                    {
                                        <a href="javascript:" class="editOperate print-code" data-id="@info.Id">打印二维码</a>
                                        <span class="btn-line">|</span>
                                    }
                                    @Html.ActionLink("生成二维码", "ReNewDiningTableQRCode", new {id = info.Id}, new {@class = "editOperate"})
                                    <span class="btn-line">|</span>
                                    @Html.ActionLink("编辑", "EditDiningTable", new {id = info.Id}, new {@class = "editOperate"})
                                    <span class="btn-line">|</span>
                                    @Html.ActionLink("删除", "DeleteDiningTable", new {id = info.Id}, new {@class = "editOperate"})

                                </td>

                            </tr>
                        }
                        </tbody>
                    </table>
                </td>
            </tr>
        </table>        
        
    </div>

    <script>

        $(function () {
            $(".print-code").click(function () {
                downloadCode($(this).attr("data-id"));
            });
        })

        //打印二维码
        function downloadCode(id) {
            var url = '@Url.Action("PrintDiningTableQrCode")';
            $.post(url, { id: id }, function (data) {
                data = JSON.parse(data);
                if (data.Code != 0) {
                    $.jBox.tip(data.Message);
                    return;
                }
                var imgUrl = data.Data
                window.location.href = imgUrl;
            });
        }

    </script>
}